package com.zzyy.study.service;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.zzyy.study.entities.Product;
import com.zzyy.study.entities.Student;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @auther zzyy
 * @create 2024-06-30 9:42
 */
@Service
public class MyService
{

    @Resource
    private StudentService studentService;
    @Resource
    private ProductService productService;

    @DSTransactional(rollbackFor = Exception.class)
    public void saveAll()
    {
        System.out.println(studentService.save(new Student(IdUtil.simpleUUID(), RandomUtil.randomInt(20,30))));

        System.out.println(productService.save(new Product("小米手机4",RandomUtil.randomInt(4000,6000))));
        int age = 10/0;
    }
}
